<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('断档报表')"/>
    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            物料名称：
                            <select name="itemCode">
                                <option value="">全部</option>
                                <option v-for="(item, index) in items" :key="index" :value="item.itemCode" v-cloak>{{item.itemName}}</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
<!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="BoxItemSoldOut:export">-->
<!--                <i class="fa fa-download"></i> 导出-->
<!--            </a>-->
            <a class="btn btn-primary" onclick="$.table.print()">
                <i class="fa fa-plus"></i> 打印
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table" data-mobile-responsive="true" style="white-space: nowrap"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "boxItem/BoxItemSoldOut";

    var app = new Vue({
        el: '.container-div',
        data: {
            items: []
        },
        methods: {
            getItems: function(){
                var that = this;
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: "/system/itemInfo/findList",
                    data: {},
                    async: false,
                    error: function(request){
                        $.modal.alertError("系统错误");
                    },
                    success: function(data){
                        that.items = data.rows;
                    }
                });
            }
        },
        created(){
            this.getItems();
        }
    })

    $(function () {
        var options = {
            url: prefix + "/findList",
            exportUrl: prefix + "/export",
            modalName: "断档报表数据",
            columns: [
                {
                    field: 'itemName',
                    title: '物料名称',
                    align: 'center',
                    visible: true
                },
                {
                    field: 'quantity',
                    title: '数量',
                    align: 'center',
                    visible: true
                },
                {
                    field: 'warn',
                    title: '库存预警最低数量',
                    align: 'center',
                    visible: true
                }
            ]
        };
        $.table.init(options);
    });
</script>
</body>
</html>
